<template>
  <bm-overlay
    ref="customOverlay"
    pane="labelPane"
    @draw="draw">
    <span v-text="text"></span>
    <div v-text="txt"></div>
  </bm-overlay>
</template>

<script>
export default {
  props: ['text', 'position', 'active', 'txt'],
  watch: {
    position: {
      handler () {
        this.$refs.customOverlay.reload()
      },
      deep: true
    }
  },
  methods: {
    draw ({ el, BMap, map }) {
      const { lng, lat } = this.position
      const pixel = map.pointToOverlayPixel(new BMap.Point(lng, lat))
      el.style.left = pixel.x - 60 + 'px'
      el.style.top = pixel.y - 20 + 'px'
    }
  }
}
</script>

<style>

</style>
